<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * This is a sample module for PyroCMS
 *
 * @author 		Jerel Unruh - PyroCMS Dev Team
 * @website		http://unruhdesigns.com
 * @package 	PyroCMS
 * @subpackage 	Sample Module
 */
class Admin extends Admin_Controller
{

	public function __construct()
	{
		parent::__construct();

		// Load all the required classes
		$this->load->model('dataman_m');
		$this->load->model('general_m');
		 
		$this->lang->load('dataman');

		$this->template->set_partial('shortcuts', 'admin/partials/shortcuts')
						->append_metadata(js('admin.js', 'dataman'))
						->append_metadata(css('admin.css', 'dataman'));
	}

	/**
	 * List all items
	 */
	public function index()
	{
		$this->template->title($this->module_details['name'])->build('admin/items', $this->data);
	}
	
	function general(){
		$route = $this->uri->segment(4,'');
		$this->template->append_metadata(js('general.js', 'dataman')); 
		$this->load->library('module_helper');
		switch($route){
			default:
				$this->data = $this->general_m->index();
				$this->template->title($this->module_details['name'])
						->build('admin/general/index', $this->data);
				break;
		}
	}	
/*
	public function create_item()
	{
		// Set the validation rules
		$this->form_validation->set_rules($this->item_validation_rules);

		if($this->form_validation->run())
		{
			// Create the item
			if($this->dataman_m->create_item($_POST))
			{
				// All good...
				$this->session->set_flashdata('success', lang('sample.success'));
				redirect('admin/sample');
			}
			// Something went wrong..
			else
			{
				$this->session->set_flashdata('error', lang('sample.error'));
				redirect('admin/sample/create_item');
			}
		}

		// Load the view
		$this->template->title($this->module_details['name'], lang('sample.new_item'))
						->build('admin/create_item', $this->data);
	}*/
	
	public function city_zip()
	{
		$cities = $this->dataman_m->get_cities();
		$this->data->cities =& $cities;
		// Set the validation rules
		$this->form_validation->set_rules($this->item_validation_rules);
/*
		if($this->form_validation->run())
		{
			// Create the item
			if($this->dataman_m->create_item($_POST))
			{
				// All good...
				$this->session->set_flashdata('success', lang('sample.success'));
				redirect('admin/sample');
			}
			// Something went wrong..
			else
			{
				$this->session->set_flashdata('error', lang('sample.error'));
				redirect('admin/sample/create_item');
			}
		}
*/
		// Load the view
		$this->template->title($this->module_details['name'], lang('dataman.locations'))
						->build('admin/city_zip', $this->data);
	}
}
